//
//  TKYAnalysisController.m
//  StationHouseHelper
//
//  Created by apple on 2018/5/4.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYAnalysisController.h"
#import "TKYChangeStationHouseController.h"
#import "UIViewController+CWLateralSlide.h"
#import "TKYSurveyCell.h"
#import "TKYProgressSumCell.h"
//#import "TKYTaskSumCell.h"

#define KSurveyCellID @"TKYSurveyCell"
#define kProgressSumCellID @"TKYProgressSumCell"
#define KTaskSumCellID @"TKYTaskSumCell"
@interface TKYAnalysisController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong)BaseTabelView *tabelView;


@end

@implementation TKYAnalysisController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //界面设置
    [self setUPUI];
    
}

/**
 设置界面
 */
- (void)setUPUI{
    self.navigationItem.title = @"分析";
    self.navigationController.navigationBar.barTintColor = KNavColor;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:19.0]}];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"切换站房" style:UIBarButtonItemStylePlain target:self action:@selector(changeStationHouseBarButtonItem:)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"消息中心" style:UIBarButtonItemStylePlain target:self action:@selector(messageCerterAction:)];
    
    [self.view addSubview:self.tabelView];
}

//切换站点
- (void)changeStationHouseBarButtonItem:(UIBarButtonItem *)barButtonItem{
    TKYChangeStationHouseController *vc = [[TKYChangeStationHouseController alloc] init];
    
    vc.drawerType = DrawerTypeMaskLeft;
    
    //[self cw_pushViewController:vc drewerHiddenDuration:0.01];
    
    [self cw_showDrawerViewController:vc animationType:CWDrawerAnimationTypeMask configuration:nil];
}

- (void)messageCerterAction:(UIBarButtonItem *)barButtonItem{
    
    
}

#pragma mark-- UITableViewDataSource,UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 150;
    }else if(indexPath.section == 1){
        return 130;
    }else{
        return 300;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.00001;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 1;
    }else if (section == 1){
        return 1;
    }else{
        return 1;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        TKYSurveyCell *cell = [tableView dequeueReusableCellWithIdentifier:KSurveyCellID];
        return cell;
    }else if (indexPath.section == 1){
        TKYProgressSumCell *sumCell = [tableView dequeueReusableCellWithIdentifier:kProgressSumCellID];
        return sumCell;
    }else{
        TKYProgressSumCell *sumCell = [tableView dequeueReusableCellWithIdentifier:kProgressSumCellID];
        return sumCell;
    }
}

#pragma mark--- 懒加载
- (BaseTabelView *)tabelView {
    if (_tabelView == nil) {
        _tabelView = [[BaseTabelView alloc]initWithFrame:CGRectMake(0, MyNavBarHeight, kScreenWidth, kScreenHeight) style:UITableViewStyleGrouped];
        _tabelView.delegate = self;
        _tabelView.dataSource = self;
        [_tabelView registerNib:[UINib nibWithNibName:@"TKYSurveyCell" bundle:nil] forCellReuseIdentifier:KSurveyCellID];
        [_tabelView registerNib:[UINib nibWithNibName:@"TKYProgressSumCell" bundle:nil] forCellReuseIdentifier:kProgressSumCellID];
       // [_tabelView registerClass:[TKYTaskSumCell class] forCellReuseIdentifier:KTaskSumCellID];
    }
    return _tabelView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
